package cn.xspace.library.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xspace.android.xafcommon.been.MediaBean;

import java.util.List;

import cn.xspace.library.R;
import cn.xspace.library.view.GalleryViewHolder;

/**
 * liuchen 创建于 2017/1/17.
 */
public class GalleryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private LayoutInflater mInflater;
    private List<MediaBean> mDataList;
    private Context mContext;
    private IDeleteOne iDeleteListener;

    private int fromType = 0;

    public GalleryAdapter(Context context, List<MediaBean> mDataList, IDeleteOne iDeleteListener, int type) {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        this.mDataList = mDataList;
        this.iDeleteListener = iDeleteListener;
        fromType = type;
    }


    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    /**
     * 创建ViewHolder
     */
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View view = mInflater.inflate(R.layout.item_qac_file, viewGroup, false);
        return new GalleryViewHolder(view, mContext, iDeleteListener, fromType);
    }

    /**
     * 设置值
     */

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int i) {
        ((GalleryViewHolder) viewHolder).bindHolder(mDataList.get(i));
    }


    public interface IDeleteOne {
        void onDeleteOne(MediaBean bean);

        void onItemClick(View view, MediaBean bean);

        void onVoiceClick(ImageView view, TextView textView, MediaBean bean);
    }
}
